﻿<UserControl x:Class="HeritageAcademy.Library.Controls.TestBoardListBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:Controls="clr-namespace:HeritageAcademy.Library.Controls" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
    mc:Ignorable="d" 
    d:DesignWidth="240">

    <Grid x:Name="FlyoutGrid" RenderTransformOrigin="0,0" SnapsToDevicePixels="True">

		<Controls:CalloutShape ArrowAlignment="Left" ArrowHeight="30" ArrowPlacement="None" ArrowWidth="30" StrokeThickness="0" Margin="0" Fill="{DynamicResource SoftDarkUIBrush}" />

        <!-- Content Area -->
		<Grid Margin="0">
			<Grid.Resources>
                <!-- Separator -->
				<Style TargetType="{x:Type Separator}">
					<Setter Property="Margin" Value="0" />
					<Setter Property="SnapsToDevicePixels" Value="True" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type Separator}">
								<StackPanel>
									<Rectangle Height="1" Fill="#50000000" />
									<Rectangle Height="1" Fill="#18FFFFFF" />
								</StackPanel>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
                <!-- RadioButton -->
				<Style TargetType="{x:Type RadioButton}">
					<Setter Property="OverridesDefaultStyle" Value="True" />
					<Setter Property="FocusVisualStyle" Value="{x:Null}" />
					<Setter Property="SnapsToDevicePixels" Value="True" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type RadioButton}">
								<Border x:Name="Border" Background="Transparent" BorderBrush="Transparent" BorderThickness="0,2,0,1"  >
									<ContentPresenter Margin="{TemplateBinding Padding}" />
								</Border>
								<ControlTemplate.Triggers>
									<Trigger Property="IsMouseOver" Value="True">
										<Setter TargetName="Border" Property="Background" Value="{DynamicResource LogoBackgroundBrush}" />
									</Trigger>
									<Trigger Property="IsFocused" Value="True">
										<Setter TargetName="Border" Property="Background" Value="{DynamicResource LogoBackgroundBrush}" />
									</Trigger>
									<Trigger Property="IsChecked" Value="True">
										<Setter TargetName="Border" Property="Background" Value="Transparent" />
									</Trigger>
								</ControlTemplate.Triggers>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
                <!-- Expander -->
				<Style TargetType="{x:Type Expander}">
					<Setter Property="OverridesDefaultStyle" Value="True" />
					<Setter Property="FocusVisualStyle" Value="{x:Null}" />
					<Setter Property="SnapsToDevicePixels" Value="True" />
					<Setter Property="Padding" Value="0" />
					<Setter Property="Foreground" Value="White" />
					<Setter Property="MinHeight" Value="36" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type Expander}">
								<StackPanel x:Name="StackPanel" Margin="0,0,0,0">
									<Border x:Name="HeaderBorder" Cursor="Hand" Background="Transparent">
										<Grid Margin="16,8">
											<Grid.ColumnDefinitions>
												<ColumnDefinition Width="16" />
												<ColumnDefinition Width="*" />
											</Grid.ColumnDefinitions>
											<Path x:Name="Arrow" Margin="0,1,0,0" Width="7" Height="9" Data="{StaticResource RightArrow}" Fill="#60FFFFFF" Stretch="Fill" HorizontalAlignment="Left">
												<Path.LayoutTransform>
													<RotateTransform x:Name="ArrowRotator" Angle="0" />
												</Path.LayoutTransform>
											</Path>
											<ContentPresenter Grid.Column="1" ContentSource="Header" Margin="0,0,0,0" TextElement.FontSize="14" TextElement.FontWeight="Bold" />
										</Grid>
									</Border>
									<Controls:Reveal x:Name="Reveal" Duration="200">
										<ContentPresenter x:Name="ContentHost" ContentSource="Content" Margin="0,0,0,8" Width="{Binding ActualWidth, ElementName=StackPanel}" />
									</Controls:Reveal>
								</StackPanel>
								<ControlTemplate.Triggers>
									<Trigger Property="IsExpanded" Value="True">
										<Trigger.EnterActions>
											<BeginStoryboard>
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="ArrowRotator" Storyboard.TargetProperty="Angle" To="90" Duration="00:00:00.1" />
												</Storyboard>
											</BeginStoryboard>
										</Trigger.EnterActions>
										<Trigger.ExitActions>
											<BeginStoryboard>
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="ArrowRotator" Storyboard.TargetProperty="Angle" Duration="00:00:00.1" />
												</Storyboard>
											</BeginStoryboard>
										</Trigger.ExitActions>
										<Setter TargetName="Reveal" Property="IsExpanded" Value="True" />
										<Setter TargetName="HeaderBorder" Property="Cursor" Value="Arrow" />
									</Trigger>
								</ControlTemplate.Triggers>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
                <!-- Button -->
				<Style TargetType="{x:Type Button}">
					<Setter Property="OverridesDefaultStyle" Value="True" />
					<Setter Property="FocusVisualStyle" Value="{x:Null}" />
					<Setter Property="SnapsToDevicePixels" Value="True" />
					<Setter Property="Foreground" Value="White" />
					<Setter Property="FontSize" Value="14" />
					<Setter Property="FontWeight" Value="Bold" />
					<Setter Property="MinHeight" Value="38" />
					<Setter Property="Padding" Value="16,7,8,7" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type Button}">
								<Border x:Name="Border" Cursor="Hand" Background="Transparent" BorderBrush="Transparent" BorderThickness="0,1">
									<ContentPresenter Margin="{TemplateBinding Padding}" VerticalAlignment="Center" />
								</Border>
								<ControlTemplate.Triggers>
									<Trigger Property="IsMouseOver" Value="True">
										<Setter TargetName="Border" Property="Background" Value="{DynamicResource LogoBackgroundBrush}" />
									</Trigger>
									<Trigger Property="IsFocused" Value="True">
										<Setter TargetName="Border" Property="Background" Value="{DynamicResource LogoBackgroundBrush}" />
									</Trigger>
								</ControlTemplate.Triggers>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
                <!-- ScrollBar -->
				<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
					<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
					<Setter Property="SnapsToDevicePixels" Value="True"/>
					<Setter Property="OverridesDefaultStyle" Value="true"/>
					<Setter Property="IsTabStop" Value="false"/>
					<Setter Property="Focusable" Value="false"/>
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type RepeatButton}">
								<Border Background="Transparent"/>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
				<Style x:Key="HorizontalScrollBarThumb" TargetType="{x:Type Thumb}">
					<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
					<Setter Property="SnapsToDevicePixels" Value="True"/>
					<Setter Property="OverridesDefaultStyle" Value="true"/>
					<Setter Property="IsTabStop" Value="false"/>
					<Setter Property="Focusable" Value="false"/>
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type Thumb}">
								<Grid Background="Transparent">
									<Border Height="8" Background="#FFFFFF" BorderThickness="0.5,1" CornerRadius="3"/>
								</Grid>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
				<Style x:Key="VerticalScrollBarThumb" TargetType="{x:Type Thumb}">
					<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
					<Setter Property="SnapsToDevicePixels" Value="True"/>
					<Setter Property="OverridesDefaultStyle" Value="true"/>
					<Setter Property="IsTabStop" Value="false"/>
					<Setter Property="Focusable" Value="false"/>
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type Thumb}">
								<Grid Background="Transparent">
									<Border Width="8" Background="#FFFFFF" BorderThickness="1,0.5" CornerRadius="3" HorizontalAlignment="Left"/>
								</Grid>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
				<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
					<Grid Width="16">
						<Track x:Name="PART_Track" IsDirectionReversed="true">
							<Track.DecreaseRepeatButton>
								<RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource ScrollBarPageButton}"/>
							</Track.DecreaseRepeatButton>
							<Track.Thumb>
								<Thumb x:Name="Thumb" Opacity="0.15" Style="{StaticResource VerticalScrollBarThumb}"/>
							</Track.Thumb>
							<Track.IncreaseRepeatButton>
								<RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource ScrollBarPageButton}"/>
							</Track.IncreaseRepeatButton>
						</Track>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Trigger.EnterActions>
								<BeginStoryboard>
									<Storyboard>
										<DoubleAnimation Duration="0:0:0.25" Storyboard.TargetName="Thumb" Storyboard.TargetProperty="Opacity" To="1"/>
									</Storyboard>
								</BeginStoryboard>
							</Trigger.EnterActions>
							<Trigger.ExitActions>
								<BeginStoryboard>
									<Storyboard>
										<DoubleAnimation Duration="0:0:0.25" Storyboard.TargetName="Thumb" Storyboard.TargetProperty="Opacity"/>
									</Storyboard>
								</BeginStoryboard>
							</Trigger.ExitActions>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
				<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
					<Grid Height="26">
						<Border Height="6" Background="#18000000" CornerRadius="3"/>
						<Track x:Name="PART_Track" IsDirectionReversed="false">
							<Track.DecreaseRepeatButton>
								<RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource ScrollBarPageButton}"/>
							</Track.DecreaseRepeatButton>
							<Track.Thumb>
								<Thumb x:Name="Thumb" Opacity="0.25" Style="{StaticResource HorizontalScrollBarThumb}"/>
							</Track.Thumb>
							<Track.IncreaseRepeatButton>
								<RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource ScrollBarPageButton}"/>
							</Track.IncreaseRepeatButton>
						</Track>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Trigger.EnterActions>
								<BeginStoryboard>
									<Storyboard>
										<DoubleAnimation Duration="0:0:0.25" Storyboard.TargetName="Thumb" Storyboard.TargetProperty="Opacity" To="1"/>
									</Storyboard>
								</BeginStoryboard>
							</Trigger.EnterActions>
							<Trigger.ExitActions>
								<BeginStoryboard>
									<Storyboard>
										<DoubleAnimation Duration="0:0:0.25" Storyboard.TargetName="Thumb" Storyboard.TargetProperty="Opacity"/>
									</Storyboard>
								</BeginStoryboard>
							</Trigger.ExitActions>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
				<Style TargetType="{x:Type ScrollBar}">
					<Setter Property="SnapsToDevicePixels" Value="True"/>
					<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
					<Setter Property="OverridesDefaultStyle" Value="true"/>
					<Setter Property="Template" Value="{StaticResource VerticalScrollBar}"/>
					<Style.Triggers>
						<Trigger Property="Orientation" Value="Horizontal">
							<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}"/>
						</Trigger>
					</Style.Triggers>
				</Style>
				<Style TargetType="{x:Type ScrollViewer}">
					<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
					<Setter Property="OverridesDefaultStyle" Value="True"/>
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type ScrollViewer}">
								<Grid>
									<ScrollContentPresenter Grid.Column="1"/>
									<ScrollBar x:Name="PART_VerticalScrollBar" Maximum="{TemplateBinding ScrollableHeight}" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" HorizontalAlignment="Right"/>
								</Grid>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
				<Style x:Key="ActionButton" TargetType="{x:Type Button}">
					<Setter Property="OverridesDefaultStyle" Value="True"/>
					<Setter Property="SnapsToDevicePixels" Value="True"/>
					<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
					<Setter Property="Padding" Value="0,0,0,0"/>
					<Setter Property="Cursor" Value="Hand"/>
					<Setter Property="MinHeight" Value="36"/>
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type Button}">
								<Grid>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="*"/>
										<ColumnDefinition Width="Auto"/>
									</Grid.ColumnDefinitions>
									<Border x:Name="MouseOverBorder" CornerRadius="2" BorderThickness="0,1" Grid.ColumnSpan="2" Opacity="0" Background="{DynamicResource LogoBackgroundBrush}" />

									<ContentPresenter x:Name="ContentHost" Margin="0,0,20,0" VerticalAlignment="Center"/>
								</Grid>
								<ControlTemplate.Triggers>
									<Trigger Property="IsMouseOver" Value="True">
										<Trigger.EnterActions>
											<BeginStoryboard>
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="00:00:00" />
												</Storyboard>
											</BeginStoryboard>
										</Trigger.EnterActions>
										<Trigger.ExitActions>
											<BeginStoryboard>
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="Opacity" Duration="00:00:00" />
												</Storyboard>
											</BeginStoryboard>
										</Trigger.ExitActions>
										<Setter TargetName="ContentHost" Property="Margin" Value="0" />
									</Trigger>
								</ControlTemplate.Triggers>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
			</Grid.Resources>

			<StackPanel Margin="0,0,0,0">
				<TextBlock FontSize="26.667" Foreground="White" Text="ТЕСТЫ" Margin="0,-12,0,10" VerticalAlignment="Top" HorizontalAlignment="Center" TextOptions.TextFormattingMode="Display" FontWeight="Medium" />
				<Separator />
				<ScrollViewer x:Name="Scroll" MaxHeight="325" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
                    <ItemsControl x:Name="icViewer" ItemsSource="{Binding TestsTitles}" >
						<ItemsControl.ItemTemplate>
							<DataTemplate>
								<Button Style="{StaticResource ActionButton}" 
                                        Content="{Binding}"
                                        FontWeight="Normal" 
                                        FontSize="12" 
                                        Foreground="White" 
                                        Margin="0"
                                        Command="{Binding SelectTestCommand}"
                                        Click="Button_Click">
                                        <!--Command="{Binding SelectTestCommand, diagnostics:PresentationTraceSources.TraceLevel=High}">-->
									<Button.ContentTemplate>
										<DataTemplate>
											<Grid Margin="20,0,0,0" HorizontalAlignment="Left" >
												<Grid.ColumnDefinitions>
													<ColumnDefinition Width="*" />
													<ColumnDefinition Width="Auto" />
												</Grid.ColumnDefinitions>
                                                <TextBlock FontWeight="Normal" Foreground="White" FontSize="12"  Text="{Binding}" TextTrimming="CharacterEllipsis" />
												<!--<TextBlock x:Name="PageNumberText" Grid.Column="1" FontWeight="Normal"  FontSize="11"  Foreground="#50FFFFFF" Text="{Binding CurrentPageNumber, StringFormat='  (Страница \{0\})'}" />-->
											</Grid>
										</DataTemplate>
									</Button.ContentTemplate>
								</Button>
							</DataTemplate>
						</ItemsControl.ItemTemplate>
					</ItemsControl>
				</ScrollViewer>

			</StackPanel>

		</Grid>
	</Grid>
</UserControl>
